{extend name="layout/layout"}
{block name="content"}
<main class="user_page active ufm_page">
    <section class="">
        <div class="layui-main">
            <div class="user_con">
                <div class="user_headpage" data-load="user_account_headr">
                    <div class="user_header user_files w100 ">
                        <div class="block2 mr20">
                            <div class="block1 mb20 ft-bold">
                                <p class="ft18  mb16">帳號管理</p>
                                <p class="ft14 gary_c6  line2">你可以在這裡管理跟 PAYPAL 帳號 有關的所有設定。</p>
                            </div>
                            <ul class="layui-nav layui-nav-tree layui-inline w100 mt10" lay-bar="disabled">
                                <li class="layui-nav-item layui-this">
                                    <a href="javascript:;">变更Email</a>
                                </li>
                                <li class="layui-nav-item">
                                    <a href="/activity/user/password.html">变更密码</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="right_main block1">
                    <p class="t18 mb15">變更 Email</p>
                    <p class="ft15 ft-bold mb40 gary_c6">此 Email 為 PAYPAL 會員帳號，可以用來登入 PAYPAL App，以及接收活動的各種第一手資訊</p>
                    <form onsubmit="return false;" class="layui-form account-form" lay-filter="account-form">
                        <div class="layui-form-item">
                            <div class="label ">目前 Email</div>
                            <div class="">
                                <p class="gary_c9 ft14 ml15">{$user.email}</p>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="label must">新 Email</div>
                            <div class="">
                                <input type="text" name="email" lay-verify="required" placeholder="请输入新邮箱" autocomplete="off"
                                       class="layui-input email-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="label must">
                                <span>验证码</span>
                                <button class="layui-btn layui-btn-sm ml20 layui-btn-primary layui-border" onclick="sendEmailCode()">发送</button>
                            </div>
                            <div class="">
                                <input type="text" name="code" lay-verify="required" placeholder="请去邮箱查看验证码" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>

                        <div class="d-flex jc-fe layui-form-item">
                            <button class="layui-btn layui-btn-lg layui-bg-orange" onclick="saveChange()">保存变更</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</main>
<script>
    function sendEmailCode(){
        $.quickPost('/activity/user/send_email_check_code',{email:$('.account-form .email-input').val()});
    }
    function saveChange(){
        var data = layui.form.val('account-form');
        $.quickPost('/activity/user/account',data).done(res => {
            setTimeout(()=>{
                location.href='/';
            },500)
        })
    }
</script>
{/block}